#include <process.h>
#include <Windows.h>
#include <iostream>
using namespace std;


void  silly( void * );   // function prototype

int main()
{
    // Our program's first thread starts in the main() function.

    printf( "Now in the main() function.\n" );
        HANDLE *thread;
        thread = new HANDLE[1];
    // Let's now create our second thread and ask it to start
    // in the silly() function.
		int a=1;
		int b=2;

    thread[0]=(HANDLE)_beginthread( silly, 0, (void*)a );
        thread[1]=(HANDLE)_beginthread( silly, 0, (void*)b );
      //  thread[2]=(HANDLE)_beginthread( silly, 0, (void*)3 );
      //  thread[3]=(HANDLE)_beginthread( silly, 0, (void*)4 );
       // thread[4]=(HANDLE)_beginthread( silly, 0, (void*)5 );
        //thread[5]=(HANDLE)_beginthread( silly, 0, (void*)6 );
        //thread[6]=(HANDLE)_beginthread( silly, 0, (void*)7 );
    // From here on there are seven separate threads executing
    // our one program.

    // This main thread can call the silly() function if it wants to.

    silly( (void*)-5 );
  //  Sleep(5000 );

for (int i=0; i<7; i++)
                WaitForSingleObject(thread[i], INFINITE);

        cout << "All threads have finished execution!" << endl;

        return 0;


}

void  silly( void *args )		//Discuss what is being passed here an address or a direct value or a pointer , because a pointer contains an address !?
{
		int *x = ((int*)&args);									/////Discuss what is happening if we do        int *x = ((int*)args);
        cout << "value of int using void* = " << *x<< endl;		/////and then just cout << x ???
}